bitkeeper revision 1.1159.99.2 (41614eedRuLOjlI5-39Ib0z3OZYFgA)
authorcl349@freefall.cl.cam.ac.uk <cl349@freefall.cl.cam.ac.uk>
Mon, 4 Oct 2004 13:23:57 +0000 (13:23 +0000)
committercl349@freefall.cl.cam.ac.uk <cl349@freefall.cl.cam.ac.uk>
Mon, 4 Oct 2004 13:23:57 +0000 (13:23 +0000)
g/c kthread code.

netbsd-2.0-xen-sparse/sys/arch/xen/include/ctrl_if.h
netbsd-2.0-xen-sparse/sys/arch/xen/xen/ctrl_if.c
netbsd-2.0-xen-sparse/sys/arch/xen/xen/xencons.c

index 6d6bfe172fba5b79aa8b995517f65da35da84a52..79f4859e8099a663cc7a0874d48c9d3c5eef630f 100644 (file)
@@ -117,6 +117,7 @@ void ctrl_if_suspend(void);
 void ctrl_if_resume(void);
 
 /* Start-of-day setup. */
+void ctrl_if_early_init(void);
 void ctrl_if_init(void);
 
 /*
index d81068b0a111858d59f2afe622932415d7e9d60a..edeb2bed8cfb44ad90ce4718ac45b285c90a8e8d 100644 (file)
@@ -13,7 +13,6 @@ __KERNEL_RCSID(0, "$NetBSD$");
 #include <sys/systm.h>
 #include <sys/proc.h>
 #include <sys/malloc.h>
-#include <sys/kthread.h>
 
 #include <machine/xen.h>
 #include <machine/hypervisor.h>
@@ -77,8 +76,6 @@ static void __ctrl_if_tx_tasklet(unsigned long data);
 
 static void __ctrl_if_rx_tasklet(unsigned long data);
 
-static void ctrl_if_kthread(void *);
-
 #define get_ctrl_if() ((control_if_t *)((char *)HYPERVISOR_shared_info + 2048))
 #define TX_FULL(_c)   \
     (((_c)->tx_req_prod - ctrl_if_tx_resp_cons) == CONTROL_RING_SIZE)
@@ -194,34 +191,22 @@ static void __ctrl_if_rx_tasklet(unsigned long data)
     {
         __insn_barrier();
         ctrl_if_rxmsg_deferred_prod = dp;
-#if 0
-        wakeup(&ctrl_if_kthread);
-#else
        if (ctrl_if_softintr)
                softintr_schedule(ctrl_if_softintr);
-#endif
     }
 }
 
 static int ctrl_if_interrupt(void *arg)
 {
-    control_if_t *ctrl_if = get_ctrl_if();
+       control_if_t *ctrl_if = get_ctrl_if();
 
-    if ( ctrl_if_tx_resp_cons != ctrl_if->tx_resp_prod ||
-       ctrl_if_rx_req_cons != ctrl_if->rx_req_prod ) {
-#if 0
-#if 0
-           wakeup(&ctrl_if_kthread);
-#else
-           if (ctrl_if_softintr)
-                   softintr_schedule(ctrl_if_softintr);
-#endif
-#else
-           ctrl_if_kthread((void *)1);
-#endif
-    }
+       if ( ctrl_if_tx_resp_cons != ctrl_if->tx_resp_prod )
+               __ctrl_if_tx_tasklet(0);
 
-    return 0;
+       if ( ctrl_if_rx_req_cons != ctrl_if->rx_req_prod )
+               __ctrl_if_rx_tasklet(0);
+
+       return 0;
 }
 
 int
@@ -289,6 +274,7 @@ ctrl_if_send_message_block(
        while ((rc = ctrl_if_send_message_noblock(msg, hnd, id)) == EAGAIN) {
                /* XXXcl possible race -> add a lock and ltsleep */
 #if 1
+               HYPERVISOR_yield();
 #else
                rc = tsleep((caddr_t) &ctrl_if_tx_wait, PUSER | PCATCH,
                    "ctrl_if", 0);
@@ -459,50 +445,16 @@ ctrl_if_unregister_receiver(
     restore_flags(flags);
 
     /* Ensure that @hnd will not be executed after this function returns. */
-#if 0
-    wakeup(&ctrl_if_kthread);
-#else
     if (ctrl_if_softintr)
            softintr_schedule(ctrl_if_softintr);
-#endif
-}
-
-static void
-ctrl_if_kthread(void *arg)
-{
-       control_if_t *ctrl_if = get_ctrl_if();
-
-       for (;;) {
-               if ( ctrl_if_tx_resp_cons != ctrl_if->tx_resp_prod )
-                       __ctrl_if_tx_tasklet(0);
-
-               if ( ctrl_if_rx_req_cons != ctrl_if->rx_req_prod )
-                       __ctrl_if_rx_tasklet(0);
-
-               if (arg) {
-                       // printf("ctrl_if_kthread one-shot done\n");
-                       return;
-               }
-
-               tsleep((caddr_t)&ctrl_if_kthread, PUSER | PCATCH,
-                   "ctrl_if", 0);
-       }
 }
 
 static void
 ctrl_if_softintr_handler(void *arg)
 {
-       static int in_handler = 0;
-
-       if (in_handler++ != 0) {
-               ctrl_if_evtchn = -1;
-               panic("recurse");
-       }
 
        if ( ctrl_if_rxmsg_deferred_cons != ctrl_if_rxmsg_deferred_prod )
                __ctrl_if_rxmsg_deferred(NULL);
-
-       in_handler--;
 }
 
 #ifdef notyet
@@ -545,7 +497,6 @@ void ctrl_if_resume(void)
     hypervisor_enable_irq(ctrl_if_irq);
 }
 
-void ctrl_if_early_init(void);
 void ctrl_if_early_init(void)
 {
 
index 91fbccd9ed02fdd77e72f118b15e794e7302cde1..1148951eb760214d25c4727c64237a02621d2288 100644 (file)
@@ -348,7 +348,6 @@ xencons_rx(ctrl_msg_t *msg, unsigned long id)
        ctrl_if_send_response(msg);
 }
 
-void ctrl_if_early_init(void);
 void
 xenconscn_attach()
 {